package edu.hawaii.duedates;

import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

/**
 * Test the HawaiiStateLibrary class to check that it functions properly.
 * 
 * @author Erin Kim and Arthur Shum
 */
@Ignore
public class TestHawaiiStateLibrary {

  /** The patron's library barcode number. */
  private String barcode;
  
  /** The last 4 digits of the patron's phone number. */
  private String pin;
  
  /** The string (actually, part of the string) expected to be returned by the getInfo method. */
  private String expected;

  /**
   * Sets the barcode, pin and expected fields. Sets the barcode and pin fields according to the
   * system properties (passed from the command line).  Sets the expected field to the appropriate 
   * string, depending on whose library account we are checking.
   */
  @Before
  public void setExpected() {
    this.barcode = System.getProperty("hsl.barcode");
    this.pin = System.getProperty("hsl.pin");

    // 3845 currently has The Book of the Dead checked out.
    if ("3845".equalsIgnoreCase(this.pin)) {
      this.expected = "The book of the dead";
    }
    // 0769 currently has no items checked out.
    else if ("0769".equalsIgnoreCase(this.pin)) {
      this.expected = "No items checked out from the Hawaii State Public Library System";
    }
    
  }
  
  /**
   * Tests that the the string returned by the getInfo method contains the expected return string.
   * If it does, then it is almost certain that the actual returned string is correct.
   * @throws Exception If an error occurs during the test.
   */
  @Test
  public void test() throws Exception {    
    Library hsl = new HawaiiStateLibrary(this.barcode, this.pin);
    String actual = hsl.getInfo();
    Boolean equality = actual.contains(this.expected);
    assertTrue("Actual results contain expected results", equality); 
  }
  
}
